import request from '@/utils/request'

export function fetchList(query) {
  return request({
    url: '/api/permission/list',
    method: 'get',
    params: query
  })
}

export function fetchTreeData(query) {
  return request({
    url: '/api/permission/tree-data',
    method: 'get',
    params: query
  })
}

export function fetchListAllPermission() {
  return request({
    url: '/api/permission/menu-items',
    method: 'get'
  })
}

export function fetchPermission(id) {
  return request({
    url: '/api/permission/detail',
    method: 'get',
    params: { id }
  })
}

export function createPermission(data) {
  return request({
    url: '/api/permission/create',
    method: 'post',
    data
  })
}

export function updatePermission(data) {
  return request({
    url: '/api/permission/update',
    method: 'post',
    data
  })
}

export function deletePermission(id) {
  return request({
    url: '/api/permission/delete/' + id,
    method: 'post'
  })
}
